import { encodeSearchParams } from "@/utils";
import { requestCustom, requestUpload } from "./request";
import type { PageParams, PageResponse } from "./types";

export function testFetch(data: PageParams) {
  return requestCustom({
    url: "/login/info",
    method: "POST",
    data,
  });
}

export function loginAuth(data: { username: string; password: string }) {
  return requestCustom<{ satoken: string }>({
    url: "/login/auth",
    method: "POST",
    data,
  });
}

export function logoutAuth() {
  return requestCustom({
    url: "/login/logout",
    method: "POST",
  });
}

export function getUserInfo() {
  return requestCustom({
    url: "/login/info",
    method: "POST",
  });
}

// 文件上传
export function fileUpload(filePath: string) {
  return requestUpload({
    url: "/file/upload",
    filePath,
  });
}

// 新增商户
export function merchantInster(data: any) {
  return requestCustom({
    url: "/merchant",
    method: "POST",
    data,
  });
}

// 商户列表
export function merchantList(data: any, params?: PageParams) {
  return requestCustom<PageResponse>({
    url: "/merchant/list?" + encodeSearchParams(params),
    method: "POST",
    data,
  });
}

// 美团鲜花结算列表
export function mtflowerSettlement(data?: any, params?: PageParams) {
  return requestCustom<PageResponse>({
    url:
      "/mt/flower/settlement/bill/listByMobile?" + encodeSearchParams(params),
    method: "GET",
    data,
  });
}
// 美团鲜花补单列表
export function mtflowerSupply(data?: any, params?: PageParams) {
  return requestCustom<PageResponse>({
    url: "/mt/flower/supply/bill/countByMobile?" + encodeSearchParams(params),
    method: "GET",
    data,
  });
}
// 美团蛋糕结算列表
export function mtcakeSettlement(data?: any, params?: PageParams) {
  return requestCustom<PageResponse>({
    url: "/mt/cake/settlement/bill/listByMobile?" + encodeSearchParams(params),
    method: "GET",
    data,
  });
}
// 美团蛋糕补单列表
export function mtcakeSupply(data?: any, params?: PageParams) {
  return requestCustom<PageResponse>({
    url: "/mt/cake/supply/bill/listByMobile?" + encodeSearchParams(params),
    method: "GET",
    data,
  });
}
// 抖音鲜花结算列表
export function tkflowerSettlement(data?: any, params?: PageParams) {
  return requestCustom<PageResponse>({
    url:
      "/tk/flower/settlement/bill/countByMobile?" + encodeSearchParams(params),
    method: "GET",
    data,
  });
}
// 抖音鲜花补单列表
export function tkflowerSupply(data?: any, params?: PageParams) {
  return requestCustom<PageResponse>({
    url: "/tk/flower/supply/bill/countByMobile?" + encodeSearchParams(params),
    method: "GET",
    data,
  });
}
// 抖音气球结算列表
export function tkballoonSettlement(data?: any, params?: PageParams) {
  return requestCustom<PageResponse>({
    url:
      "/tk/balloon/settlement/billl/listByMobile?" + encodeSearchParams(params),
    method: "GET",
    data,
  });
}
// 抖音蛋糕结算列表
export function tkcakeSettlement(data?: any, params?: PageParams) {
  return requestCustom<PageResponse>({
    url: "/tk/cake/settlement/bill/listByMobile?" + encodeSearchParams(params),
    method: "GET",
    data,
  });
}
// 饿了么鲜花补单列表
export function eleSupply(data?: any, params?: PageParams) {
  return requestCustom<PageResponse>({
    url: "/elm/supply/bill/listByMobile?" + encodeSearchParams(params),
    method: "GET",
    data,
  });
}

// 美团鲜花结算
export function mtflowerSettlementDetail(id: number) {
  return requestCustom({
    url: `/mt/flower/settlement/bill/${id}`,
    method: "GET",
  });
}
// 美团鲜花补单
export function mtflowerSupplyDetail(
  { storeName, createDate }: { storeName: string; createDate: string },
  pageParams: PageParams
) {
  return requestCustom({
    url: `/mt/flower/supply/bill/listByStoreName?${encodeSearchParams({
      ...pageParams,
      storeName,
      createDate,
    })}`,
    method: "GET",
  });
}
// 美团蛋糕结算
export function mtcakeSettlementDetail(id: number) {
  return requestCustom({
    url: `/mt/cake/settlement/bill/${id}`,
    method: "GET",
  });
}
// 美团蛋糕补单
export function mtcakeSupplyDetail(id: number) {
  return requestCustom({
    url: `/mt/cake/supply/bill/${id}`,
    method: "GET",
  });
}
// 抖音鲜花结算
export function tkflowerSettlementDetail(
  { storeName, createDate }: { storeName: string; createDate: string },
  pageParams: PageParams
) {
  return requestCustom({
    url: `/tk/flower/settlement/bill/listByStoreName?${encodeSearchParams({
      ...pageParams,
      storeName,
      createDate,
    })}`,
    method: "GET",
  });
}

// 抖音鲜花补单
export function tkflowerSupplyDetail(
  { storeName, createDate }: { storeName: string; createDate: string },
  pageParams: PageParams
) {
  return requestCustom({
    url: `/tk/flower/supply/bill/listByStoreName?${encodeSearchParams({
      ...pageParams,
      createDate,
      storeName,
    })}`,
    method: "GET",
  });
}
// 抖音气球结算
export function tkballoonSettlementDetail(id: number) {
  return requestCustom({
    url: `/tk/balloon/settlement/billl/${id}`,
    method: "GET",
  });
}
// 抖音蛋糕结算
export function tkcakeSettlementDetail(id: number) {
  return requestCustom({
    url: `/tk/cake/settlement/bill/${id}`,
    method: "GET",
  });
}
// 饿了么鲜花补单
export function eleSupplyDetail(id: number) {
  return requestCustom({
    url: `/elm/supply/bill/${id}`,
    method: "GET",
  });
}

// 美团鲜花结算天分组列表
export function mtflowerSettlementTimelist(data?: any, params?: PageParams) {
  return requestCustom({
    url: `/mt/flower/settlement/bill/billTimelist?${encodeSearchParams(
      params
    )}`,
    method: "GET",
    data,
  });
}
// 美团鲜花补单天分组列表
export function mtflowerSupplyTimelist(data?: any, params?: PageParams) {
  return requestCustom({
    url: `/mt/flower/supply/bill/billTimelist?${encodeSearchParams(params)}`,
    method: "GET",
    data,
  });
}
// 美团蛋糕结算天分组列表
export function mtcakeSettlementTimelist(data?: any, params?: PageParams) {
  return requestCustom({
    url: `/mt/cake/settlement/bill/billTimelist?${encodeSearchParams(params)}`,
    method: "GET",
    data,
  });
}
// 美团蛋糕补单天分组列表
export function mtcakeSupplyTimelist(data?: any, params?: PageParams) {
  return requestCustom({
    url: `/mt/cake/supply/bill/billTimelist?${encodeSearchParams(params)}`,
    method: "GET",
    data,
  });
}
// 抖音鲜花结算天分组列表
export function tkflowerSettlementTimelist(data?: any, params?: PageParams) {
  return requestCustom({
    url: `/tk/flower/settlement/bill/billTimelist?${encodeSearchParams(
      params
    )}`,
    method: "GET",
    data,
  });
}
// 抖音鲜花补单天分组列表
export function tkflowerSupplyTimelist(data?: any, params?: PageParams) {
  return requestCustom({
    url: `/tk/flower/supply/bill/billTimelist?${encodeSearchParams(params)}`,
    method: "GET",
    data,
  });
}
// 抖音气球结算天分组列表
export function tkballoonSettlementTimelist(data?: any, params?: PageParams) {
  return requestCustom({
    url: `/tk/balloon/settlement/bbillTimelist?${encodeSearchParams(params)}}`,
    method: "GET",
    data,
  });
}
// 抖音蛋糕结算天分组列表
export function tkcakeSettlementTimelist(data?: any, params?: PageParams) {
  return requestCustom({
    url: `/tk/cake/settlement/bill/billTimelist?${encodeSearchParams(params)}`,
    method: "GET",
    data,
  });
}
// 饿了么鲜花补单天分组列表
export function eleSupplyTimelist(data?: any, params?: PageParams) {
  return requestCustom({
    url: `/elm/supply/bill/billTimelist?${encodeSearchParams(params)}`,
    method: "GET",
    data,
  });
}
